<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: D:/Projects/MiXiM/extsrc/mixim/src/modules/netw/WiseRoute.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00454.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">WiseRoute.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/***************************************************************************</span>
<a name="l00002"></a>00002 <span class="comment"> * file:        WiseRoute.h</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * author:      Damien Piguet, Jerome Rousselot</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * copyright:   (C) 2007-2009 CSEM SA, Neuchatel, Switzerland.</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> * description: Implementation of the routing protocol of WiseStack.</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> *              This program is free software; you can redistribute it</span>
<a name="l00011"></a>00011 <span class="comment"> *              and/or modify it under the terms of the GNU General Public</span>
<a name="l00012"></a>00012 <span class="comment"> *              License as published by the Free Software Foundation; either</span>
<a name="l00013"></a>00013 <span class="comment"> *              version 2 of the License, or (at your option) any later</span>
<a name="l00014"></a>00014 <span class="comment"> *              version.</span>
<a name="l00015"></a>00015 <span class="comment"> *              For further information see file COPYING</span>
<a name="l00016"></a>00016 <span class="comment"> *              in the top level directory</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> * Funding: This work was partially financed by the European Commission under the</span>
<a name="l00019"></a>00019 <span class="comment"> * Framework 6 IST Project &quot;Wirelessly Accessible Sensor Populations&quot;</span>
<a name="l00020"></a>00020 <span class="comment"> * (WASP) under contract IST-034963.</span>
<a name="l00021"></a>00021 <span class="comment"> ***************************************************************************</span>
<a name="l00022"></a>00022 <span class="comment"> * ported to Mixim 2.0.1 by Theodoros Kapourniotis</span>
<a name="l00023"></a>00023 <span class="comment"> * last modification: 06/02/11</span>
<a name="l00024"></a>00024 <span class="comment"> **************************************************************************/</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <span class="preprocessor">#ifndef wiseroute_h</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span><span class="preprocessor">#define wiseroute_h</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;map&gt;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;omnetpp.h&gt;</span>
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="preprocessor">#include &quot;MiXiMDefs.h&quot;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &quot;BaseNetwLayer.h&quot;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &quot;SimpleAddress.h&quot;</span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="keyword">class </span><a class="code" href="a00202.html">SimTracer</a>;
<a name="l00037"></a>00037 <span class="keyword">class </span>WiseRoutePkt;
<a name="l00038"></a>00038 
<a name="l00053"></a><a class="code" href="a00227.html">00053</a> <span class="keyword">class </span>MIXIM_API <a class="code" href="a00227.html" title="Wiseroute is a simple loop-free routing algorithm that builds a routing tree from a central network p...">WiseRoute</a> : <span class="keyword">public</span> <a class="code" href="a00028.html" title="Base class for the network layer.">BaseNetwLayer</a>
<a name="l00054"></a>00054 {
<a name="l00055"></a>00055 <span class="keyword">private</span>:
<a name="l00058"></a>00058   <a class="code" href="a00227.html" title="Wiseroute is a simple loop-free routing algorithm that builds a routing tree from a central network p...">WiseRoute</a>(<span class="keyword">const</span> <a class="code" href="a00227.html" title="Wiseroute is a simple loop-free routing algorithm that builds a routing tree from a central network p...">WiseRoute</a>&amp;);
<a name="l00061"></a>00061   <a class="code" href="a00227.html" title="Wiseroute is a simple loop-free routing algorithm that builds a routing tree from a central network p...">WiseRoute</a>&amp; <a class="code" href="a00028.html#ac736985952cb46f7340488218e23ae57" title="Assignment operator is not allowed.">operator=</a>(<span class="keyword">const</span> <a class="code" href="a00227.html" title="Wiseroute is a simple loop-free routing algorithm that builds a routing tree from a central network p...">WiseRoute</a>&amp;);
<a name="l00062"></a>00062 
<a name="l00063"></a>00063 <span class="keyword">public</span>:
<a name="l00064"></a>00064   <a class="code" href="a00227.html" title="Wiseroute is a simple loop-free routing algorithm that builds a routing tree from a central network p...">WiseRoute</a>()
<a name="l00065"></a>00065     : <a class="code" href="a00028.html" title="Base class for the network layer.">BaseNetwLayer</a>()
<a name="l00066"></a>00066     , routeTable()
<a name="l00067"></a>00067     , floodTable()
<a name="l00068"></a>00068     , <a class="code" href="a00028.html#a9b802bd94a739e6202690d743ecc83a2" title="Length of the NetwPkt header Read from omnetpp.ini.">headerLength</a>(0)
<a name="l00069"></a>00069     , macaddress()
<a name="l00070"></a>00070     , sinkAddress()
<a name="l00071"></a>00071     , useSimTracer(<span class="keyword">false</span>)
<a name="l00072"></a>00072     , rssiThreshold(0)
<a name="l00073"></a>00073     , routeFloodsInterval(0)
<a name="l00074"></a>00074     , floodSeqNumber(0)
<a name="l00075"></a>00075     , tracer(NULL)
<a name="l00076"></a>00076     , routeFloodTimer(NULL)
<a name="l00077"></a>00077     , nbDataPacketsForwarded(0)
<a name="l00078"></a>00078     , nbDataPacketsReceived(0)
<a name="l00079"></a>00079     , nbDataPacketsSent(0)
<a name="l00080"></a>00080     , nbDuplicatedFloodsReceived(0)
<a name="l00081"></a>00081     , nbFloodsSent(0)
<a name="l00082"></a>00082     , nbPureUnicastSent(0)
<a name="l00083"></a>00083     , nbRouteFloodsSent(0)
<a name="l00084"></a>00084     , nbRouteFloodsReceived(0)
<a name="l00085"></a>00085     , nbUnicastFloodForwarded(0)
<a name="l00086"></a>00086     , nbPureUnicastForwarded(0)
<a name="l00087"></a>00087     , nbGetRouteFailures(0)
<a name="l00088"></a>00088     , nbRoutesRecorded(0)
<a name="l00089"></a>00089     , nbHops(0)
<a name="l00090"></a>00090     , receivedRSSI()
<a name="l00091"></a>00091     , routeRSSI()
<a name="l00092"></a>00092     , allReceivedRSSI()
<a name="l00093"></a>00093     , allReceivedBER()
<a name="l00094"></a>00094     , routeBER()
<a name="l00095"></a>00095     , receivedBER()
<a name="l00096"></a>00096     , nextHopSelectionForSink()
<a name="l00097"></a>00097     , trace(<span class="keyword">false</span>), stats(<span class="keyword">false</span>), <a class="code" href="a00027.html#af32711ea117b066fcd10081a17bb81d4" title="Debug switch for all other modules.">debug</a>(<span class="keyword">false</span>)
<a name="l00098"></a>00098   {}
<a name="l00100"></a>00100     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00028.html#a1e521b5549bfe29ae94d95265c0fe8d2" title="Initialization of the module and some variables.">initialize</a>(<span class="keywordtype">int</span>);
<a name="l00101"></a>00101     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00025.html#a5ab11502dbeeea89693d29841376a2f7" title="Called when the simulation has finished.">finish</a>();
<a name="l00102"></a>00102 
<a name="l00103"></a>00103     <span class="keyword">virtual</span> ~<a class="code" href="a00227.html" title="Wiseroute is a simple loop-free routing algorithm that builds a routing tree from a central network p...">WiseRoute</a>();
<a name="l00104"></a>00104 
<a name="l00105"></a>00105 <span class="keyword">protected</span>:
<a name="l00106"></a>00106   <span class="keyword">enum</span> messagesTypes {
<a name="l00107"></a>00107       UNKNOWN=0,
<a name="l00108"></a>00108       DATA,
<a name="l00109"></a>00109       ROUTE_FLOOD,
<a name="l00110"></a>00110       SEND_ROUTE_FLOOD_TIMER
<a name="l00111"></a>00111   };
<a name="l00112"></a>00112 
<a name="l00113"></a>00113   <span class="keyword">typedef</span> <span class="keyword">enum</span> floodTypes {
<a name="l00114"></a>00114     NOTAFLOOD,
<a name="l00115"></a>00115     FORWARD,
<a name="l00116"></a>00116     FORME,
<a name="l00117"></a>00117     DUPLICATE
<a name="l00118"></a>00118   } floodTypes;
<a name="l00119"></a>00119 
<a name="l00120"></a>00120 
<a name="l00121"></a><a class="code" href="a00219.html">00121</a>   <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="a00219.html">tRouteTableEntry</a> {
<a name="l00122"></a>00122     <a class="code" href="a00117.html#ad85cd9e8d9e7e9cd5d02dd740c4a12a4" title="Type definition for a L3 (Network) address.">LAddress::L3Type</a> nextHop;
<a name="l00123"></a>00123     <span class="keywordtype">double</span>           rssi;
<a name="l00124"></a>00124   } <a class="code" href="a00219.html">tRouteTableEntry</a>;
<a name="l00125"></a>00125 
<a name="l00126"></a>00126   <span class="keyword">typedef</span> std::map&lt;LAddress::L3Type, tRouteTableEntry&gt;        tRouteTable;
<a name="l00127"></a>00127   <span class="keyword">typedef</span> std::multimap&lt;tRouteTable::key_type, unsigned long&gt; tFloodTable;
<a name="l00128"></a>00128 
<a name="l00129"></a>00129   tRouteTable routeTable;
<a name="l00130"></a>00130   tFloodTable floodTable;
<a name="l00131"></a>00131 
<a name="l00136"></a><a class="code" href="a00227.html#a85496f386487b74241f1f49dc2382018">00136</a>     <span class="keywordtype">int</span> <a class="code" href="a00227.html#a85496f386487b74241f1f49dc2382018" title="Length of the NetwPkt header Read from omnetpp.ini.">headerLength</a>;
<a name="l00137"></a>00137 
<a name="l00139"></a>00139 <span class="comment">//    int myNetwAddr;</span>
<a name="l00140"></a><a class="code" href="a00227.html#a7133c22ad06dc95ee4c0c3cb28128d47">00140</a>     <a class="code" href="a00117.html#aea56b60dcb5ae8c2bde465271daf7210" title="Type definition for a L2 (MAC) address.">LAddress::L2Type</a> <a class="code" href="a00227.html#a7133c22ad06dc95ee4c0c3cb28128d47" title="cached variable of my network address">macaddress</a>;
<a name="l00141"></a>00141 
<a name="l00142"></a>00142     <a class="code" href="a00117.html#ad85cd9e8d9e7e9cd5d02dd740c4a12a4" title="Type definition for a L3 (Network) address.">LAddress::L3Type</a> sinkAddress;
<a name="l00143"></a>00143 
<a name="l00144"></a>00144     <span class="keywordtype">bool</span> useSimTracer;
<a name="l00145"></a>00145 
<a name="l00147"></a><a class="code" href="a00227.html#a54b8e7bd6fc7ac3dcb1712bcd242d73d">00147</a>     <span class="keywordtype">double</span> <a class="code" href="a00227.html#a54b8e7bd6fc7ac3dcb1712bcd242d73d" title="Minimal received RSSI necessary for adding source to routing table.">rssiThreshold</a>;
<a name="l00148"></a>00148 
<a name="l00152"></a><a class="code" href="a00227.html#a129155f4064558e95b461cd5e222bf79">00152</a>     <span class="keywordtype">double</span> <a class="code" href="a00227.html#a129155f4064558e95b461cd5e222bf79" title="Interval [seconds] between two route floods. A route flood is a simple flood from which other nodes c...">routeFloodsInterval</a>;
<a name="l00153"></a>00153 
<a name="l00155"></a><a class="code" href="a00227.html#a033281ae1ebaa9bc4badf3a4e1a3a330">00155</a>     <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="a00227.html#a033281ae1ebaa9bc4badf3a4e1a3a330" title="Flood sequence number.">floodSeqNumber</a>;
<a name="l00156"></a>00156 
<a name="l00157"></a>00157     <a class="code" href="a00202.html">SimTracer</a> *tracer;
<a name="l00158"></a>00158     cMessage* routeFloodTimer;
<a name="l00159"></a>00159 
<a name="l00160"></a>00160     <span class="keywordtype">long</span> nbDataPacketsForwarded;
<a name="l00161"></a>00161     <span class="keywordtype">long</span> nbDataPacketsReceived;
<a name="l00162"></a>00162     <span class="keywordtype">long</span> nbDataPacketsSent;
<a name="l00163"></a>00163     <span class="keywordtype">long</span> nbDuplicatedFloodsReceived;
<a name="l00164"></a>00164     <span class="keywordtype">long</span> nbFloodsSent;
<a name="l00165"></a>00165     <span class="keywordtype">long</span> nbPureUnicastSent;
<a name="l00166"></a>00166     <span class="keywordtype">long</span> nbRouteFloodsSent;
<a name="l00167"></a>00167     <span class="keywordtype">long</span> nbRouteFloodsReceived;
<a name="l00168"></a>00168     <span class="keywordtype">long</span> nbUnicastFloodForwarded;
<a name="l00169"></a>00169     <span class="keywordtype">long</span> nbPureUnicastForwarded;
<a name="l00170"></a>00170     <span class="keywordtype">long</span> nbGetRouteFailures;
<a name="l00171"></a>00171     <span class="keywordtype">long</span> nbRoutesRecorded;
<a name="l00172"></a>00172     <span class="keywordtype">long</span> nbHops;
<a name="l00173"></a>00173 
<a name="l00174"></a>00174     cOutVector receivedRSSI;
<a name="l00175"></a>00175     cOutVector routeRSSI;
<a name="l00176"></a>00176     cOutVector allReceivedRSSI;
<a name="l00177"></a>00177     cOutVector allReceivedBER;
<a name="l00178"></a>00178     cOutVector routeBER;
<a name="l00179"></a>00179     cOutVector receivedBER;
<a name="l00180"></a>00180     cOutVector nextHopSelectionForSink;
<a name="l00181"></a>00181 
<a name="l00182"></a><a class="code" href="a00227.html#aa20b4f21d71d01e0a25ff690b3004f21">00182</a>     <span class="keywordtype">bool</span> trace, stats, <a class="code" href="a00227.html#aa20b4f21d71d01e0a25ff690b3004f21" title="Debug switch for all other modules.">debug</a>;
<a name="l00183"></a>00183 
<a name="l00194"></a>00194 
<a name="l00196"></a>00196     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00028.html#a0b473fbb2517ac7b0c633afdb002c269" title="Handle messages from upper layer.">handleUpperMsg</a>(cMessage* msg);
<a name="l00197"></a>00197 
<a name="l00199"></a>00199     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00028.html#a58afc64e0a96fe4d80d6b9f53cfd53c6" title="Handle messages from lower layer.">handleLowerMsg</a>(cMessage* msg);
<a name="l00200"></a>00200 
<a name="l00202"></a>00202     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00028.html#a1b6a30a1442d646a41df5acc7ef1e047" title="Handle self messages.">handleSelfMsg</a>(cMessage* msg);
<a name="l00203"></a>00203 
<a name="l00205"></a>00205     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00028.html#a478dcd88ab7a82412deb8075afe61278" title="Handle control messages from lower layer.">handleLowerControl</a>(cMessage* msg);
<a name="l00206"></a>00206 
<a name="l00212"></a>00212     <span class="keyword">virtual</span> <span class="keywordtype">void</span> updateRouteTable(<span class="keyword">const</span> tRouteTable::key_type&amp; origin, <span class="keyword">const</span> <a class="code" href="a00117.html#ad85cd9e8d9e7e9cd5d02dd740c4a12a4" title="Type definition for a L3 (Network) address.">LAddress::L3Type</a>&amp; lastHop, <span class="keywordtype">double</span> rssi, <span class="keywordtype">double</span> ber);
<a name="l00213"></a>00213 
<a name="l00215"></a>00215     cMessage* <a class="code" href="a00028.html#a5e35aa24556a7cab9b6658889e98cb74" title="decapsulate higher layer message from NetwPkt">decapsMsg</a>(WiseRoutePkt *msg);
<a name="l00216"></a>00216 
<a name="l00220"></a>00220     floodTypes updateFloodTable(<span class="keywordtype">bool</span> isFlood, <span class="keyword">const</span> tFloodTable::key_type&amp; srcAddr, <span class="keyword">const</span> tFloodTable::key_type&amp; destAddr, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> seqNum);
<a name="l00221"></a>00221 
<a name="l00223"></a>00223     tFloodTable::key_type getRoute(<span class="keyword">const</span> tFloodTable::key_type&amp; destAddr, <span class="keywordtype">bool</span> iAmOrigin = <span class="keyword">false</span>) <span class="keyword">const</span>;
<a name="l00224"></a>00224 };
<a name="l00225"></a>00225 
<a name="l00226"></a>00226 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><b>WiseRoute.h</b>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:30 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
